<!-- 通用形配置 -->
<template>
  <div style="margin-top:16px">
    <el-form-item label="配置列表">
      <el-button size="mini" type="primary" @click="openCode">编辑</el-button>
    </el-form-item>
    <codeedit @submit="codeClose"
              v-model="code.content"
              :visible.sync="code.box"></codeedit>
  </div>
</template>

<script>
import codeedit from '../../views/build/code.vue';
export default {
  components: {
    codeedit
  },
  inject: ["main"],
  props: {
    config: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {
      code: {
        box: false,
        content: "",
        type: "echartFormatter",
      },
    };
  },
  computed: {
    myConfig() {
      return this.config;
    },
  },

  methods: {
    codeClose(value) {
        this.main.activeObj[this.code.type] = value;
    },
    openCode() {
        this.code.content = this.main.activeObj[this.code.type];
        this.code.box = true;
    },
  },
};
</script>